<template>
    <div>
        <router-view/>
        <van-tabbar v-model="mainActive">
            <van-tabbar-item icon="shop" to="/">订单</van-tabbar-item>
            <van-tabbar-item icon="shop" to="/commodity">商品管理</van-tabbar-item>
            <van-tabbar-item icon="records" to="/bill">账单</van-tabbar-item>
            <van-tabbar-item icon="records" to="/member">会员</van-tabbar-item>
        </van-tabbar>
    </div>
</template>

<script>
    export default {
        name: "Main",
        data() {
            return {
                mainActive: 0
            }
        },
        created: function () {
            const vm = this;
            let path = vm.$route.path;
            /*if (!localStorage.UUBuserId) {
                vm.$router.push({path: '/login'})
            }*/
            switch (path) {
                case '/commodity':
                    vm.mainActive = 1
                    break;
                case '/bill':
                    vm.mainActive = 2
                    break;
                case '/member':
                    vm.mainActive = 3
                    break;
                default:
                    vm.mainActive = 0
                    break;
            }
        }
    }
</script>

<style scoped>

</style>